<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('username', 50)->comment('账号');
            $table->string('password', 255)->comment('密码');
            $table->string('email', 50)->default('')->comment('邮箱');
            $table->string('real_name', 20)->default('')->comment('真实姓名');
            $table->enum('sex', [1, 2])->default(1)->comment('性别 1男士 2女士');
            $table->enum('status', [0, 1])->default(1)->comment('状态 1可用 0禁用');
            $table->char('last_login_ip', 15)->default('')->comment('最后登陆ip');
            $table->unsignedInteger('last_login_time')->default('0')->comment('最后登录时间');
            $table->unsignedInteger('login_times')->default('0')->comment('登录次数');
            $table->unsignedInteger('created_at')->default('0')->comment('添加时间');
            $table->unsignedInteger('created_by')->default('0')->comment('添加人');
            $table->unsignedInteger('updated_at')->default('0')->comment('修改时间');
            $table->unsignedInteger('updated_by')->default('0')->comment('修改人');
            $table->unsignedInteger('deleted_at')->default('0')->comment('删除时间');
            $table->unsignedInteger('deleted_by')->default('0')->comment('删除人');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
